#ifndef _EXT_NOT_LOG_H_
#define _EXT_NOT_LOG_H_

#include <stdint.h>

#ifdef __cplusplus
extern "C"
{
#endif

#define FLASH_NOR_ERR_NONE 0
#define FLASH_NOR_ERR_SECSIZE 1 
#define FLASH_NOR_ERR_NORSIZE 2 
#define FLASH_NOR_ERR_BLKSIZE 3 
#define FLASH_NOR_ERR_DATSIZE 4 
#define FLASH_NOR_ERR_NORBASE 5 
#define FLASH_NOR_ERR_DATOVE 6  
#define FLASH_NOR_ERR_DATOVK 7  
#define FLASH_NOR_ERR_BLKOVE 8  
#define FLASH_NOR_ERR_DATPER 9  
#define FLASH_NOR_ERR_EMPTY 10  
#define FLASH_NOR_ERR_DATBL 11  
#define FLASH_NOR_ERR_NORSST 12 
#define FLASH_NOR_ERR_BLKSEC 13 
#define FLASH_NOR_ERR_BLOCKS 14 
#define FLASH_NOR_ERR_PGSIZE 15 

    typedef struct
    {
        uint32_t addr_next;       
        uint32_t addr_data_start; 
        uint16_t Err;             
        uint16_t Checked;         
        uint32_t site_next;       
        uint32_t site_start;      
    } ext_nor_log_Info_Type;

    typedef const struct
    {
        uint32_t EepBase;                                               
        uint32_t EepSize;                                               
        uint32_t SectorSize;                                            
        uint32_t PageSize;                                              
        uint32_t DataSize;                                              
        uint32_t blocks_per_sector;                                     
        uint32_t blocks;                                                
        uint8_t *Data;                                                  
        uint32_t *WorkBuff;                                             
        ext_nor_log_Info_Type *Info;                                    
        uint8_t (*Erase)(uint32_t AddrBase, uint32_t Nums);             
        uint8_t (*Program)(uint32_t Addr, uint32_t Len, uint8_t *Data); 
        uint8_t (*Read)(uint32_t Addr, uint32_t Len, uint8_t *Data);    
    } ext_nor_log_Cfg_Type;

    uint16_t nor_log_flash_check(ext_nor_log_Cfg_Type *EepCfg);
    
    uint16_t nor_log_flash_save(ext_nor_log_Cfg_Type *EepCfg);
    
    uint16_t nor_log_flash_alain(ext_nor_log_Cfg_Type *EepCfg);
    
    uint16_t nor_log_head_search(ext_nor_log_Cfg_Type *EepCfg, uint32_t head_val, uint32_t num, uint32_t *addr_des);

    uint16_t nor_log_fixed_head_search(ext_nor_log_Cfg_Type *EepCfg, uint32_t num, uint32_t *addr_des);

    uint16_t nor_log_time_search(ext_nor_log_Cfg_Type *EepCfg, uint32_t time, uint32_t *addr_des);

#ifdef __cplusplus
}
#endif

#endif
